package com.tanhua.server.interceptor;

import com.tanhua.model.domain.User;

public class UserHolder {
    private static ThreadLocal<User> t1=new ThreadLocal<User>();
    //将用户存入线程中
    public static void set(User user){
        t1.set(user);
    }
    //从线程获取用户对象
    public static User get(){
        return t1.get();
    }
    //从线程获取用户id
    public static Long getUserId(){
        return t1.get().getId();
    }
    //从线程获取手机号
    public String getMobile(){
        return t1.get().getMobile();
    }
    //清空线程中的数据
    public static void remove(){
        t1.remove();
    }
}
